﻿using Learun.Application.TwoDevelopment.ZZDT_EC;
using Learun.Util;
using System;
using System.Web.Http;

namespace Learun.Application.Web.AppApi
{
    /// <summary>
    /// 信号模板（By ChenGT）
    /// </summary>
    [HandlerApiLogin(FilterMode.Enforce)]
    [TokenAuthorize]
    public class WireGroupTemplateApiController : WebApiControllerBase
    {
        #region 模块对象
        private ec_Wire_Group_TemplateIBLL ec_Wire_Group_TemplateIBLL = new ec_Wire_Group_TemplateBLL();
        #endregion
        #region 信号模板
        /// <summary>
        /// 标准库的信号模板列表（不需要projId，只有查项目级的才有意义）
        /// </summary> 
        /// <returns></returns>
        [HttpGet]
        public IHttpActionResult GetList()
        {
            try
            {
                var res = ec_Wire_Group_TemplateIBLL.GetList("{\"ProjectId\":\"\"}");
                return Success(res);
            }
            catch (Exception ex)
            {
                return Fail(ex.Message);
            }
        }
        /// <summary>
        /// 初始化项目信号（从公司级的某个模板下的所有信号复制到项目级）
        /// </summary> 
        /// <param name="WireGroupTemplateID">信号模板编号</param>
        /// <param name="projId">项目编号</param>
        /// <returns></returns>
        [HttpPost]
        public IHttpActionResult InitProjectWireGroupTemplate(string WireGroupTemplateID, string projId)
        {
            try
            {
                if (string.IsNullOrEmpty(projId.Trim()))
                {
                    return Fail("请选择项目！");
                }
                ec_Wire_Group_TemplateIBLL.InitProjectWireGroupTemplate(WireGroupTemplateID, projId);
                return Success("OK");
            }
            catch (Exception e)
            {

                return Fail(e.Message);
            }
        }
        #endregion
    }
}